import { pubRequire } from '@utils/public'
const baseUrl = '/circles'
// 获取列表
export function getSearchList(obj, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/search`, obj, callBack, errBack)
}
// 新增圈子
export function addCircle(obj, callBack, errBack) {
  return pubRequire('post', `${baseUrl}`, obj, callBack, errBack)
}
// 置顶
export function toTopApi(id, callBack, errBack) {
  return pubRequire('put', `${baseUrl}/${id}/top`, '', callBack, errBack)
}
// 取消置顶
export function unTopApi(id, callBack, errBack) {
  return pubRequire('put', `${baseUrl}/${id}/untop`, '', callBack, errBack)
}
// 停用
export function stopApi(id, callBack, errBack) {
  return pubRequire(
    'put',
    `${baseUrl}/${id}/status/disable`,
    '',
    callBack,
    errBack
  )
}
// 开启
export function openApi(id, callBack, errBack) {
  return pubRequire(
    'put',
    `${baseUrl}/${id}/status/enable`,
    '',
    callBack,
    errBack
  )
}
// 停用圈子的内容发布
export function stopPub(id, callBack, errBack) {
  return pubRequire(
    'put',
    `${baseUrl}/${id}/publish/disable`,
    '',
    callBack,
    errBack
  )
}
// 开启圈子的内容发布
export function openPub(id, callBack, errBack) {
  return pubRequire(
    'put',
    `${baseUrl}/${id}/publish/enable`,
    '',
    callBack,
    errBack
  )
}
//根据 ids 获取圈子
export function circleInfo(obj, callBack, errBack) {
  return pubRequire('get', `${baseUrl}`, obj, callBack, errBack)
}
//根据 id 获取圈子
export function circleInfoById(id, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/${id}`, '', callBack, errBack)
}
//修改圈子
export function editCircle(id, obj, callBack, errBack) {
  return pubRequire('put', `${baseUrl}/${id}`, obj, callBack, errBack)
}
//获取圈子下的成员列表
export function getMemberList(circleId, obj, callBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/${circleId}/users`,
    obj,
    callBack,
    errBack
  )
}
//删除圈子成员
export function delMember(circleId, obj, callBack, errBack) {
  return pubRequire(
    'delete',
    `${baseUrl}/${circleId}/users`,
    obj,
    callBack,
    errBack
  )
}
//导入接口
export function importUrl(circleId) {
  return `${baseUrl}/${circleId}/import`
}
//下载模板接口
export function downUrl() {
  return `${baseUrl}/download`
}

/*圈子排序*/
export function circleOrder(obj, callbBack, errBack) {
  return pubRequire(
    'patch',
    `${baseUrl}/${obj.id}/sort/${obj.num}`,
    {},
    callbBack,
    errBack
  )
}

//获取圈子字典
export function getCirclesOptions(callBack, errBack) {
  return pubRequire('get', `${baseUrl}/options`, {}, callBack, errBack)
}